Skip to content

fix(timer): restart completed timer from typed duration#26

Merged
ryota-murakami merged 1 commit into
mainfrom
codex/fix-completed-timer-restart
Jun 24, 2026
Merged

fix(timer): restart completed timer from typed duration#26
ryota-murakami merged 1 commit into
mainfrom
codex/fix-completed-timer-restart

Conversation

@ryota-murakami

@ryota-murakami ryota-murakami commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Restart completed timers from the selected typed duration instead of stale timeRemaining: 0
  • Keep zero-duration starts inert
  • Add an E2E regression for restarting after completion without pressing +/- stepper buttons

Root cause

After a timer completed, timeRemaining became 0 while initialTime still held the typed duration shown in the Minutes/Seconds inputs. start() used only timeRemaining, so Start briefly entered running state with a 0-second target and immediately completed again.

Tests

  • pnpm lint
  • pnpm typecheck
  • pnpm exec playwright test e2e/timer-behavior.spec.ts -g "completed timer restarts" --project="Desktop Chrome"
  • pnpm exec playwright test e2e/timer-behavior.spec.ts --project="Desktop Chrome"
  • pnpm e2e:desktop
  • pnpm build

Summary by CodeRabbit

  • New Features

    • Timer now resumes from the last entered duration when started again, even after finishing, without needing to adjust controls.
    • Default timer length is standardized to five minutes.
  • Bug Fixes

    • Improved timer countdown behavior so elapsed and remaining time stay accurate when starting, pausing, and completing.
    • Added coverage to verify completed timers can be restarted using the previously entered time.

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coffee-timer Ready Ready Preview, Comment Jun 24, 2026 11:49am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a9b4a6f-8acf-4b89-980e-5426fad40908

📥 Commits

Reviewing files that changed from the base of the PR and between fc0a870 and b4ea92a.

📒 Files selected for processing (3)
  • e2e/timer-behavior.spec.ts
  • lib/constants/time.ts
  • lib/stores/timerStore.ts

📝 Walkthrough

Walkthrough

Extracts MILLISECONDS_PER_SECOND and DEFAULT_TIMER_SECONDS constants into lib/constants/time.ts, replaces hardcoded literals throughout timerStore, adds a getStartDurationSeconds helper that resumes from the last typed duration on restart, and adds an e2e test verifying a completed timer restarts from the previously entered time.

Changes

Timer restart-from-typed-duration

Layer / File(s) Summary
New constants and store initialization
lib/constants/time.ts, lib/stores/timerStore.ts
Exports MILLISECONDS_PER_SECOND and DEFAULT_TIMER_SECONDS; updates the store's import group and replaces the hardcoded 300 initial values with DEFAULT_TIMER_SECONDS.
getStartDurationSeconds helper and reworked start()
lib/stores/timerStore.ts
Adds getStartDurationSeconds(timeRemaining, initialTime) to pick the countdown length on restart, guards against <= 0 durations by zeroing state, and computes targetEndTime via MILLISECONDS_PER_SECOND.
MILLISECONDS_PER_SECOND in pause/tick/updateTimeRemaining + e2e test
lib/stores/timerStore.ts, e2e/timer-behavior.spec.ts
Replaces inline 1000 literals with MILLISECONDS_PER_SECOND in all remaining ms-to-seconds conversions; adds a Playwright test that types 00:02, waits for completion, confirms inputs retain 00/02, and restarts to verify the timer counts from the typed duration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Tick tock, the bunny said,
The timer stopped, but don't feel dread!
Just press Start once more, hooray —
It hops from where you typed that day.
No stepper needed, constants shine,
Two seconds, then we're doing fine! 🕐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: restarting a completed timer from the typed duration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-completed-timer-restart

Comment @coderabbitai help to get the list of available commands.

@ryota-murakami ryota-murakami merged commit d941f83 into main Jun 24, 2026
11 checks passed
@ryota-murakami ryota-murakami deleted the codex/fix-completed-timer-restart branch June 24, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant